import { http } from "@/utils/http";

export interface IParamsForList {
  pageSize: number;
  pageNum: number;
  className?: string;
  ruleTypeName?: string;
}

export interface IRuleDescItem {
  id: number;
  className: string;
  classNameDesc: string;
  ruleTypeCode: string;
  ruleTypeName: string;
  ruleExplain: string;
  updateName: string;
  updateTime: string;
}

export type ResponseDataForList = {
  data: IRuleDescItem[];
  pageNum: number;
  pageSize: number;
  pages: number;
  total: number;
};

export type RuleForAdd = Pick<IRuleDescItem, "ruleTypeName" | "ruleExplain" | "className">;
export type RuleForUpdate = Pick<IRuleDescItem, "id" | "ruleTypeName" | "ruleExplain" | "className">;
export type ResponseDataForTypeList = Array<Pick<IRuleDescItem, "id" | "ruleTypeCode" | "ruleTypeName">>;

// 查询规则说明列表
export const getListForDesc = (data: IParamsForList) => {
  return http.request<ResponseDataForList>("post", "/digitaltwins/api/v1/equipmentStatusRuleType/queryListPage", { data });
};

export const addRuleDesc = (data: RuleForAdd) => {
  return http.request("post", "/digitaltwins/api/v1/equipmentStatusRuleType/saveStatusRuleType", { data });
};

export const updateRuleDesc = (data: RuleForUpdate) => {
  return http.request("post", "/digitaltwins/api/v1/equipmentStatusRuleType/updateStatusRuleType", { data });
};

export const deleteRuleDesc = (id: IRuleDescItem["id"]) => {
  return http.request("post", `/digitaltwins/api/v1/equipmentStatusRuleType/delStatusRuleType/${id}`);
};

export const getRuleInfo = (id: IRuleDescItem["id"]) => {
  return http.request<IRuleDescItem>("post", `/digitaltwins/api/v1/equipmentStatusRuleType/getStatusRuleType/${id}`);
};

export const getListForRuleType = (data: { className?: string; ruleTypeName?: string }) => {
  return http.request<ResponseDataForTypeList>("post", "/digitaltwins/api/v1/equipmentStatusRuleType/queryAllList", { data });
};
